package com.lancoo.znbkxx.teacher.aibkTestCoach.aibkDialog

import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.PaperEvaluationInfor
import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.lancoo.znbkxx.teacher.R
import kotlinx.android.synthetic.main.aibk_adapter_item_evaluation_export.*
import kotlinx.android.synthetic.main.aibk_dialog_evaluation_export.*
import java.util.ArrayList

/**
 * auther: 王国龙
 *  Date：2020.06.28
 * describe:答题暂停
 */
class DialogEvaluationExport(
        context: Context?,
        val activity: AppCompatActivity,
        val paperEvaluationInfor: PaperEvaluationInfor
) : Dialog(context!!, R.style.CustomDialog) {
    /**
     * 提交按钮
     */
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.aibk_dialog_evaluation_export)
        window!!.setGravity(Gravity.CENTER) //设置弹窗右对齐
        window!!.setWindowAnimations(R.style.MyDialogScale) //设置动画效果

        //按空白处可以取消动画
        setCanceledOnTouchOutside(true)
        //初始化界面数据
        initExportView()
    }

    private fun initExportView() {

        LlExportLoadingView.visibility = View.GONE
        LlExportContentView.visibility = View.VISIBLE
        SBtnExport.setOnClickListener {
            clickExportListener!!.onExportEva()
        }

        val listTags: MutableList<String> = ArrayList()
        if(paperEvaluationInfor.CommentExportTags.AnswerAnalysis) {
            listTags.add("试题解析")
        }
        if(paperEvaluationInfor.CommentExportTags.ListenText) {
            listTags.add("听力原文")
        }
        if(paperEvaluationInfor.CommentExportTags.ListenVideo) {
            listTags.add("听力音频")
        }
        if(paperEvaluationInfor.CommentExportTags.Zsd) {
            listTags.add("试题知识点")
        }

        var manager = LinearLayoutManager(activity)
        manager.orientation = LinearLayoutManager.VERTICAL
        RvEvaluationExport.layoutManager = manager
        val mAdapter = AdapterEvluationEvport(activity,paperEvaluationInfor,listTags)
        RvEvaluationExport.adapter = mAdapter
    }



    private var clickExportListener: OnClickExportListener? = null

    /*
   * 设置答题卡题号点击事件
   * */
    interface OnClickExportListener {
        fun onExportEva()//导出讲评
    }

    fun setClickExportListener(clickExportListener: OnClickExportListener?) {
        this.clickExportListener = clickExportListener
    }
}